//
//  TYFormData.h
//  TYUIKit_Example
//
//  Created by 谢航宇 on 2023/3/20.
//  Copyright © 2023 谢航宇. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger,TYFormItemType){
    ///仅展示内容
    TYFormItemTypeText,
    ///点击项
    TYFormItemTypeArrow,
    ///单行输入框
    TYFormItemTypeTextField,
    ///文本输入框
    TYFormItemTypeTextView,
    ///自定义
    TYFormItemTypeCustom
    
};



@class TYFormItem;
@interface TYFormData : NSObject
@property (nonatomic,retain) NSMutableArray <TYFormItem *>* itemArray;
- (instancetype)initWithItemArray:(NSMutableArray *)itemArray;
- (NSMutableDictionary *)requestParameters;
@end

@protocol TYFormItemDelegate <NSObject>

- (NSString *)parameter;

@end

@interface TYFormItem : NSObject
- (instancetype)initWithType:(TYFormItemType)type;

///数据类型
@property (nonatomic,assign) TYFormItemType type;

///标题
@property (nonatomic,copy) NSString * title;

///是否有新值
@property (nonatomic,assign) BOOL isNew;

///数据源，用于存储
@property (nonatomic,retain) id resource;
///数据，取(currentValue>oldValue)的description值
@property (nonatomic,retain) id <TYFormItemDelegate>value;
///当前数据，取description值
@property (nonatomic,retain) id <TYFormItemDelegate>currentValue;
///旧数据，取description值
@property (nonatomic,retain) id <TYFormItemDelegate>oldValue;

///文本行数，默认1行
@property (nonatomic,assign) NSInteger numberOfLine;

///提示信息
@property (nonatomic,copy) NSString * placeholder;

///服务器交互关键字
@property (nonatomic,copy) NSString * key;

///服务器交互参数值，默认取value的description值，如需设置其他值，请实现value的- (NSString *)parameter 方法
@property (nonatomic,copy) NSString * parameter;
@end

NS_ASSUME_NONNULL_END
